<template>
<div>

    <div><h1>添加标签</h1></div>
    <div v-width="400" class="addt">
        <br>
        <div>
            标签ID&nbsp;&nbsp;<input type="text" v-model="tagid">
        </div>
        货物类型
        <select name="" v-model="gid">
		    <option v-for="item in param" :value="item.id">{{item.name}}</option>
        </select>
        <br>
        分配用户
        <select name="" v-model="uid">
		    <option v-for="item in userlist" :value="item.id">{{item.username}}</option>
        </select>
        <br>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <Button color="primary"  @click="submit">确认添加</Button>
  </div>
</div>
</template>

<style>
    .addt {
    background-color: rgb(219, 221, 224);
    line-height: 60px;
    border-radius: 10px;
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%,-50%);
  }
</style>

<script>
import { addtag_post,genreshow_post,showuser_post,adtag_post } from './axios_api/api';
export default {
  data() {
    return {
        param:[],
        userlist:[],
        tagid:"",
        select:"",
        gid:"",
        uid:""
    };
  },
  mounted(){
      this.show_genre();
      this.show_user();
  },
  methods: {
      submit(){
          var type = localStorage.getItem('type')
          var data = {tid:this.tagid,uid:this.uid,gid:this.gid}
          if(type==5){
              adtag_post(data).then(resp=>{
                this.$Message(resp.message)
            })
          }else{
              this.$Message("权限不足")
          }
      },
      show_genre(){
          genreshow_post().then(resp=>{
              this.param = resp.genrelist;
              console.log(this.param);
          })
      },
      show_user(){
          showuser_post().then(resp=>{
              this.userlist = resp.userlist;
              console.log(this.userlist);
          })
      },

  }
};
</script>
